Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
isset($_POST['value']) data is not recieved by php

I'm trying to send some values from a javascript file with POST to a php page.

AJAX code:

let inputval = $input.val();
$.ajax({url: "../checkout/test.php", type : 'post', data : {'inputval': inputval}, success: 
function(data){ 
                console.log(data);
              }

PHP code

 if (isset($_POST['inputval'])){
        $result = $_POST['inputval'];
        echo json_encode($result);
    }
    else {
        echo 'Not recieved';
    }

When I check it in networks all is as expected, but when I open the actual page the data is not recieved.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

when I open the actual page the data is not recieved.

First you make a POST request using JavaScript. The data is visible in the network tab. It it sent to the PHP program. The PHP program responds. The response is logged to the console.

Then you "open the actual page". This is a new request. It is not the POST request with the data. $_POST will be empty this time. The response will be the response to the new request, not the previous POST request. Since the content of the response depends on $_POST and that has changed, this response is different.

If you want to store the inputval data from the first request and then display it in subsequent requests you need to explicitly store it somewhere (such as a database or a session variable) and then check that location for data when you receive the subsequent request.

The logic would run something like:

IF this is a POST request
    store the inputval in the session
    send a confirmation message to the client
ELSE IF the session contains an inputval
    send it to the client
ELSE
    send a message to say that there is no data to the client
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda